#define _CRT_SECURE_NO_WARNINGS 1

#include<stdio.h>
#include<math.h>

int Num(int  n) {
	if (n<=9)
		return 1;
	else
		return Num(n / 10) + 1;
}

int Sum(int n,int num) {
	if (n <= 9)
		return pow(n,num);
	else {
		return Sum(n / 10, num) + pow( n % 10, num);
	}
}

void judge_lily(int n) {
	int  num = Num(n);
	if (n == Sum(n,num)) {
		printf("%d ", n);
	}

}

int main() {
	for (int i = 0; i <= 10000; i++) {
		judge_lily(i);
	 }
	return 0;
}